{% extends "base.html" %}
{% block title %}{{people.name}}的相册 / {{album.topic}}{% endblock %}

{% block headerlink %}
<link href="/static/css/common.css" rel="stylesheet" type="text/css" media="all" />
<link href="/static/css/people_home.css" rel="stylesheet" type="text/css" media="all" />
<link href="/static/css/login_reg.css" rel="stylesheet" type="text/css" media="all" />
<link href="/static/css/photo.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="/static/js/jquery.min.js"></script>

<script type="text/javascript"> 
$(document).ready(function()
{
	$("#delete-photo a").each(function(event)
	{
		$(this).click(function()
		{		
			if (confirm("确定删除这张照片?") == true)
			{
				url = $(this).attr('data');
				delete_photo(url);
			}
        });
    });
    
    $("#delete-album").click(function(event)
	{
		if (confirm("确定删除这个相册?") == true)
		{
			delete_album()
		}
    });
    
    function delete_album()
    {
        $.post("delete/",
        {},
        function(data)
        {
        	if(data.status=="success")
        		window.location.href='{{ request.HOME_PAGE_URL }}people/{{people.id}}/albums/';
        	else if(data.status=="only_one_album")
				alert("请至少保留一个相册！");
        	else
        		alert(data.status);
        },
        "json"
    );}
    
    function delete_photo(url)
    {
        $.post(url,
        {},
        function(data)
        {
        	if(data.status=="success")
        	{
        		window.location.href='{{ request.HOME_PAGE_URL }}photos/{{people.id}}/albums/{{album.id}}/';
        	}
        	else
        	{
        		alert(data.status);
        	}
        },
        "json"
    );}
});
</script>
{% endblock %}

{% block content %}
<div class="content-area" style="float:left;width:inherit;">

<h1 style="margin-top:0;" class="green-link">
<a href="{{ request.HOME_PAGE_URL }}people/{{people.id}}/albums/" title="{{people.name}}的相册">{{people.name}}的相册</a> / {{album.topic}}
</h1>

{% ifequal album.photo_count 0 %}
	<div style="margin-top:30px;">
	{% if is_myPage %}
		<span class="blue-link">
		这个相册现在还没有照片，你可以<a href="{{ request.HOME_PAGE_URL }}photos/upload/">添加照片</a>
		</span>
	{% else %}
		这个相册现在还没有照片
	{% endif %}
	</div>
{% else %}
<div style="float:left;width:inherit;">
	<div style="float:left;">
	<a href="{{ request.HOME_PAGE_URL }}photos/{{people.id}}/albums/{{album.id}}/"><img src={{album.cover_loc}}></a>
	</div>
	<div style="float:left;width:650px;">
		<div style="float:left;margin-left:15px;font-size:20px;">
		{{album.topic}}
		</div>
		<div style="clear:both;float:left;margin-left:15px;margin-top:10px;font-size:14px;">
		{{album.caption}}
		</div>
	</div>
	<div class="fright">
		<div class="fright" style="color:#999;font-size:12px;text-align:right;margin-bottom:5px;">
		<div style="margin-bottom:5px;">
		<span>{{album.photo_count}}张照片</span>
		<span style="margin-left:10px;">{{album.view_count}}次浏览</span>
		</div>
		<div style="clear:both;float:right;">创建于{{album.date_created|date:"F j, Y"}}</div>
		</div>
		{% if is_myPage %}
		<div style="clear:both;font-size:12px;float:right;">
		<span class="blue-link" style="margin-right:10px"><a href="{{ request.HOME_PAGE_URL }}photos/{{people.id}}/albums/{{album.id}}/edit/" title="修改相册属性">&gt;修改相册属性</a></span>
		<span class="blue-link" style="margin-right:10px"><a href="{{ request.HOME_PAGE_URL }}photos/upload/" title="添加照片">&gt;添加照片</a></span>
		<span class="delete-link"><a id="delete-album" href="#" title="将相册以及相册中的所有照片一并删除，确定吗?">&gt;删除相册</a></span>
		</div>
		{% endif %}
	</div>
</div>
<div class="photo-list" style="width:inherit;">
	{% for p_item in p_items %} 
	<div class="photo-grid-wrapper">
	{% for photo in p_item %}
		<div class="photo-grid">
			<a href="{{ request.HOME_PAGE_URL }}photos/{{people.id}}/{{photo.id}}/">
			<img src={{photo.thumb_loc}}>
			</a>
			<div class="photo-caption">
			{{photo.caption}}
			</div>
			<div class="tags font12">
				{% for tag in photo.tag_list %} 
				<span class="tag tag-link"><a href="{{ request.HOME_PAGE_URL }}search/?q={{tag.name}}">{{tag.name}}</a></span>
				{% endfor %}
			</div>
			<div style="margin-top:5px;" class="set-details-text cleft">
			上传于<span>{{photo.date_posted}}</span>
			</div>
			<div style="clear:both;">
				<div class="set-details-text">
				{{photo.like_count}}人喜欢
				</div>
				{% if is_myPage %}
				<div style="font-size:12px;float:right;" id="delete-photo">
				<span class="delete-link"><a data="{{ request.HOME_PAGE_URL }}photos/{{people.id}}/{{photo.id}}/delete/" href="#" title="删除这张照片?">&gt;删除照片</a></span>
				</div>
				{% endif %}
			</div>
		</div>
	{% endfor %}
	</div>
	{% endfor %}
</div>

{% endifequal %}
</div>
{% endblock %}